package com.smartmedical.patient.share.controller;

import com.smartmedical.common.core.domain.HealthR;
import com.smartmedical.patient.share.domain.Banners;
import com.smartmedical.patient.share.domain.PopularSearch;
import com.smartmedical.patient.share.domain.Search;
import com.smartmedical.patient.share.service.BannersService;
import com.smartmedical.patient.share.service.InformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("share/v1")
public class BannersController {
    @Autowired
    private BannersService bannersService;
    @Autowired
    private InformationService informationService;

    /**
     * 获取轮播图
     * @return
     */
    @GetMapping("bannersShow")
    public HealthR<List<Banners>> bannersShow(){
        List<Banners> banners  =bannersService.bannersShow();
        return HealthR.ok(banners);
    }
    /**
     * 热门搜索
     */
    @GetMapping("popularSearch")
    public HealthR<List<PopularSearch>> popularSearch(){
        return HealthR.ok(informationService.popularSearch());
    }
    /**
     * 首页搜索
     * keyWord 关键字
     */
    @GetMapping("homePageSearch")
    public HealthR<Search> homePageSearch(@RequestParam("keyWord") String keyWord){
        Search search  =bannersService.search(keyWord);
        return HealthR.ok(search,"搜索成功");
    }
}
